<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('adm_localhost_auth',$QXARR))exit(noauth());
require_once ZEAI.'cache/config_adm.php';
if ($submitok == 'modupdate'){
	$keyvalue = $session_uid.'|'.$session_uname;
	$keyvalue = md5(md5($keyvalue));
	setcookie("localhostkey",$keyvalue,time()+60*60*24*360,"/",$_ZEAI['CookDomain']);
	AddLog('【本机访问授权】->【'.$session_uname.'(ID：'.$session_uid.')】');
	alert_adm("授权成功",SELF);
}elseif ($submitok == 'modupdateNO'){
	setcookie("localhostkey","",time()+60*60*24*360,"/",$_ZEAI['CookDomain']);
	setcookie("localhostkey",""); 
	AddLog('【本机访问授权】->【'.$session_uname.'(ID：'.$session_uid.')】');
	alert_adm("取消成功",SELF);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
</head>
<body class="body">
<form action="<?php echo SELF;?>" method="post" name="FORM" id="FORM">
<table width="700" height="116" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#eeeeee" style="margin-top:80px">
<tr>
<td height="80" align="center" bgcolor="#FFFFFF" class="S14"><span class="S16">授权总开关</span>：<input type="checkbox" name="localhost_auth" id="localhost_auth" class="switch" value="1"<?php echo ($_ADM['localhost_auth'] == 1)?' checked':'';?>><label for="localhost_auth" class="switch-label"><i></i><b>开启</b><b>关闭</b></label>　<div class="C999">开启后，没有经过授权的电脑将不能操作后台和CRM</div></td>
</tr>
<tr>
<td height="80" align="center" bgcolor="#FFFFFF" class="S18">
<?php if (!empty($localhostkey)){ ?>
<b><font color="#009900"><i class="ico">&#xe60f;</i> 已授权</font></b>
<?php }else{  ?>
<b><font color="#FF0000">未授权</font></b>
<?php }?>
</td>
</tr>
<tr>
<td align="center" bgcolor="#fff">
<?php if (!empty($localhostkey)){ ?>
<input type="submit" name="Submit" value="取消本机授权" class="btn size4"  />
<input name="submitok" type="hidden" value="modupdateNO" />
<?php }else{  ?>
<input type="submit" name="Submit" value="生成本机授权"  class="btn size4" />
<input name="submitok" type="hidden" value="modupdate" />
<?php }?>
</td>
</tr>
<tr>
<td align="left" bgcolor="#FFFFFF" class="lineH200 S14" style="padding:20px"><div>1．没有经过授权的主系统管理员帐号和CRM红娘帐号将不能进入后台，授权方法：在需要授权的电脑上登录超级管理员帐号点击上面的【授权按钮】进行操作，注：需要有【本机授权管理】和【管理员用户组】操作权限方可操作。</div><div>2．因采用客户端Cookies功能验证，授权后，请不要清空或关闭浏览器Cookies功能，否则密钥将丢失，需要重新授权。</div></td>
</tr>
</table>
</form>
<script>
localhost_auth.onclick = function(){
	zeai.ajax({url:'<?php echo HOST;?>/sub/cache'+zeai.extname,data:{submitok:'adm_localhost_auth',uu:'<?php echo $session_uid;?>',pp:'<?php echo $session_pwd;?>'}},function(e){var rs=zeai.jsoneval(e);
		zeai.msg(rs.msg);
		if (rs.flag == 1){setTimeout(function(){location.reload(true);},1000);}
	});
}
</script>
<?php require_once 'bottomadm.php';?>